<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="copyright" content="Tencent"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>我的优惠券</title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/mobile_coupon_public.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/mobile_coupon_style.css" />
    <style>
  
    </style>
</head>
<body>
    <div class="content_tab">
        <ul class="nav">
            <li class="on">优惠券</li>
           <!--  <li>说明介绍</li> -->
        </ul> 
        <div class="container">
            <ul class="surrent">
                
                <div style="clear:both;"></div>
            </ul>
            <!-- <ul>
               <div class="smjs">
                    <h3>说明介绍</h3>
                    <p>1、现金券面额30元，永久有效；</p>
                    <p>2、凭券到店任意消费可抵用商品金额30元，仅限京津     冀地区餐厅使用，每笔消费不限制现金券使用张数；</p>
                    <p>3、现金券一经购买，不可退款；</p>
                    <p>4、此券不可兑换现金、不设找赎，不单独开具发票，    可在门店消费后通过微信扫描消费单二维码开具发票。</p>
               </div>               
            </ul> -->
        </div>
    </div>

    <div class="shadeBg"></div>
    <div class="remind remind1">
        <i><img src="<%=path%>/images/marketing/close_mobile.png" /></i>
        <div class="s_bg">
            <h4 class="alert_name">双飞五毛党津贴</h4>
            <h5 class="alert_couponCode">券码:9374012237</h5>
        </div>
        <ul class="s_con">
            <li>
                <span>有效期限:</span>
                <em class="alert_expireTime">2017-10-23至2017-12-23</em>
            </li> 
            <li>
                <span>使用时段:</span>
                <em class="alert_useTime">周一、周二、周三、周四、周五10:00-21:00</em>
            </li>
            <li>
                <span>满减规则:</span>
                <em class="alert_limit">满200元使用</em>
            </li>
            <li>
                <span>使用说明:</span>
                <em class="useRule">每张优惠券只能使用一次</em>
            </li>
             <li>
                <span>使用说明:</span>
                <em class="useDesc">每张优惠券只能使用一次</em>
            </li>
            <!-- <li>
                <span>参与门店:</span>
                <em>上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店。</em>
            </li>   -->         
        </ul>
    </div>
    <div class="remind remind2">
        <i><img src="<%=path%>/images/marketing/close_mobile.png" /></i>
        <div class="s_bg">
            <h4 class="alert_name">双飞五毛党津贴</h4>
            <h5 class="alert_couponCode">券码:9374012237</h5>
        </div>
        <ul class="s_con">
            <li>
                <span>有效期限:</span>
                <em class="alert_expireTime">2017-10-23至2017-12-23</em>
            </li> 
            <li>
                <span>使用时段:</span>
                <em class="alert_useTime">周一、周二、周三、周四、周五10:00-21:00</em>
            </li>
            <li>
                <span>满减规则:</span>
                <em class="alert_limit">满200元使用</em>
            </li>
            <li>
                <span>使用说明:</span>
                <em class="useRule">每张优惠券只能使用一次</em>
            </li>
             <li>
                <span>使用说明:</span>
                <em class="useDesc">每张优惠券只能使用一次</em>
            </li>
            <!-- <li>
                <span>参与门店:</span>
                <em>上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店。</em>
            </li>   -->         
        </ul>
    </div>
    <div class="remind remind3">
        <i><img src="<%=path%>/images/marketing/close_mobile.png" /></i>
        <div class="s_bg">
            <h4 class="alert_name">双飞五毛党津贴</h4>
            <h5 class="alert_couponCode">券码:9374012237</h5>
        </div>
        <ul class="s_con">
            <li>
                <span>有效期限:</span>
                <em class="alert_expireTime">2017-10-23至2017-12-23</em>
            </li> 
            <li>
                <span>使用时段:</span>
                <em class="alert_useTime">周一、周二、周三、周四、周五10:00-21:00</em>
            </li>
            <li>
                <span>满减规则:</span>
                <em class="alert_limit">满200元使用</em>
            </li>
            <li>
                <span>使用说明:</span>
                <em class="useRule">每张优惠券只能使用一次</em>
            </li>
            <li>
                <span>使用说明:</span>
                <em class="useDesc">每张优惠券只能使用一次</em>
            </li>
            <!-- <li>
                <span>参与门店:</span>
                <em>上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店、上海沙龙店。</em>
            </li>   -->         
        </ul>
    </div>

 
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
	<script src="<%=path%>/js/marketing/public.js"></script>
	<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
	<script src="<%=path%>/js/system/province-city-area-data.js"></script>
    <script type="text/javascript">
        $('.nav li').click(function(){
            $(this).addClass('on').siblings().removeClass();
            var index = $(this).index();
            $('.container ul').removeClass('surrent').eq(index).addClass('surrent');
        });

        $('.remind i').click(function(){
            $('.shadeBg,.remind').hide();
        })
        
        $(document).on('click', '.coupon_yellow', function() {
        	var remindNo=this.id%3;
        	var data=JSON.parse(dataArr[this.id]);
        	$('.alert_couponCode').html("券码:"+data.coupon_code);
        	$('.alert_name').html(data.coupon_name);
        	
        	if(StringEmpty(data.start_time)){
        		$('.alert_expireTime').html(data.start_time+'—'+data.expiry_date);
			}else{
				$('.alert_expireTime').html(data.expiry_date);
			}
            var limitPrice=data.limit_price;
        	if(StringEmpty(data.limit_price)){
        		$('.alert_limit').html("满"+limitPrice/100+"元使用");
            }else{
            	$('.alert_limit').html("无");
            }
        	
            if(StringEmpty(data.period_time_week)||StringEmpty(data.period_time_hour)){
				$('.alert_useTime').html(data.period_time_week+' '+data.period_time_hour);
			}else{
				$('.alert_useTime').html('任意时间');
			} 
        	
        	if(data.useRule==0){
        		$('.useRule').html('每张优惠券只能使用一次');
        	}else{
        		$('.useRule').html('可多次使用');
        	}
        	
        	switch (remindNo) {
			case 0:
				$(".shadeBg,.remind1").show();
				break;
			case 1:
				$(".shadeBg,.remind2").show();
				break;
			case 2:
				$(".shadeBg,.remind3").show();
				break;

			default:
				break;
			}
        	
        	
        });
    </script>
    
    <script type="text/javascript">
        var cid="";
        var customer_id="";
        var ip="";
        var province="";
    	var city="";
    	var district="";
    	var couponBatchId=""
        var dataArr=new Array();
        
        $(function(){
        	init();
        })
        
        function init(){
        	cid=getQueryString("cid");
        	customer_id=getQueryString("cid");
        	couponBatchId=getQueryString("couponBatch");
        	ip=returnCitySN["cip"];
        	
			var cityName = returnCitySN["cname"];
			city=getCityCodeByName(cityName);
            getCouponList();
        }
        
        function getCouponList(){
        	var url="<%=path%>/coupon/ajaxCouponListByCid";
			$.post(url, {
				"cid" : cid,
				"customerId" : customer_id,
				"usedType": "UNVERIFY",
				"startIndex": 0,
				"pageSize": 50
			}, function(data) {
				if(data.error_code==0){
					setHtml(data.data);
				}else{
					
				}
			});
        }
        
        function setHtml(data){
        	var html="";
        	for(var i in data){
        		var id=parseInt(i)+1;
        		var jsonData=JSON.stringify(data[i]);
        		dataArr[i]=jsonData;
        		if(data[i].type==1){
        			html+='<li class="coupon_yellow s_coupon" id='+i+' couponCode="'+data[i].coupon_code+'" couponData="'+jsonData+'">';
        			html+='<h2 id="couponName">'+data[i].coupon_name+'</h2>';
        			if(data[i].validityPeriodType==0){
        				if(StringEmpty(data[i].start_time)){
        					html+='<em class="expireTime">有效期:'+data[i].start_time+'—'+data[i].expiry_date+'</em>';
        				}else{
        					html+='<em class="expireTime">有效期:'+data[i].expiry_date+'</em>';
        				}
        			}else{
        				if(StringEmpty(data[i].create_time)){
        					html+='<em class="expireTime">有效期:'+data[i].create_time+'—'+data[i].expiry_date+'</em>';
        				}else{
        					html+='有效期:<em class="expireTime">'+data[i].expiry_date+'</em>';
        				}
        				
        			}
        		}else{
        			var faceValue=data[i].face_value;
        			if(StringEmpty(faceValue)){
        				faceValue=faceValue/100;
        			}else{
        				faceValue=0;
        			}
        			html+='<li class="coupon_yellow" id='+i+' couponCode="'+data[i].coupon_code+'" couponData="'+jsonData+'">';
        			html+='<div class="left">';
        			html+='<b>￥</b><span>'+faceValue+'</span>';
                    html+='</div><div class="right">';  
                    html+='<i>'+data[i].coupon_name+'</i>';      
                    var limitPrice=data[i].limit_price;
                    if(StringEmpty(limitPrice)){
                    	html+='<i>满'+limitPrice/100+'元使用</i>';  
                    }
                    if(data[i].validityPeriodType==0){
        				if(StringEmpty(data[i].start_time)){
        					html+='<em class="expireTime">'+data[i].start_time+'—'+data[i].expiry_date+'</em></div>';
        				}else{
        					html+='<em class="expireTime">'+data[i].expiry_date+'</em></div>';
        				}
        			}else{
        				if(StringEmpty(data[i].create_time)){
        					html+='<em class="expireTime">'+data[i].create_time+'—'+data[i].expiry_date+'</em></div>';
        				}else{
        					html+='<em class="expireTime">'+data[i].expiry_date+'</em></div>';
        				}
        				
        			}
        		}
        	}
        	$('.surrent').html(html);
        }
        
        
        $(window).load(function() { 
			 createBrowse();
		});
        function createBrowse(){
        	var url="<%=path%>/socialCouponBatch/ajaxCreateCouponBrowse";
			$.post(url, {
				"cid" : cid,
				"customerId" : customer_id,
				"province":province,
				"city":city,
				"district":district,
				"ip":ip,
				"couponBatchId":couponBatchId,
			}, function(data) {
			});
        }
        
       
    
    </script>
    
</body>
</html>